package com.acme;

import com.acme.bankapp.domain.bank.*;
import com.acme.bankapp.exceptions.BankException;
import com.acme.bankapp.service.bank.BankDataLoaderService;
import com.acme.bankapp.service.bank.BankService;
import com.acme.bankapp.networking.BankServer;
import com.acme.bankapp.service.bank.Configuration;

/**
 * Created by Student on 14.11.2014.
 */
public class BankApplication {

    private static Bank bank;

    public static void main(String[] args)  {
        BankApplication.bank = new Bank();

        if (args.length < 2){
            System.out.println("Execute params error");
            return;
        }
        switch (args[0]) {
            case "-loadfeed":
                BankDataLoaderService.loadClients(bank, args[1]);
                break;
            case "-loadbank":
                BankApplication.bank = BankService.readBank(args[1]);
                break;
            case "-server":
                BankDataLoaderService.loadClients(bank, args[1]);
                BankServer.startServer(BankApplication.bank);
                break;
            case "q":
                return;
            default:
                System.out.println("Invalid argument");
                return;
        }

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        bank.stopListeners();
    }
}
